/*
 *             Copyright (C) 2024 Steve Jrong
 *
 * 	   GitHub Homepage: https://www.github.com/SteveJrong
 *      Gitee Homepage: https://gitee.com/stevejrong1024
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.stevejrong.waiter.rp.model.aggregates;

import java.time.LocalDateTime;

import com.stevejrong.waiter.rp.model.valueobjects.Status;
import com.stevejrong.waiter.rp.model.valueobjects.merchantuser.MerchantUser;

import lombok.Data;

/**
 * 聚合根（根实体） - 商家用户权限
 * <p>
 * 此类，既是聚合根，协调管理其他实体和值对象；又是普通实体，自身也可拥有属性和方法。
 *
 * @author Steve Jrong
 * @since 1.0
 */
@Data
public class MerchantUserPermission {
    private Long id; // 商家用户权限ID，同时也是聚合根（根实体）ID
    private LocalDateTime createAt; // 创建时间，是普通属性
    private LocalDateTime updateAt; // 更新时间，是普通属性

    private String name; // 商家用户的后端权限名称
    private String description; // 商家用户的后端权限描述
    private String permUrl; // 商家用户的后端权限地址后缀
    private String permCode; // 商家用户的后端权限代码

    private Status status; // 商家用户状态为枚举类型，是值对象
    private MerchantUser merchantUser; // 商家用户权限所属的商家用户，是值对象

    /**
     * 创建商家用户权限
     *
     * @return 商家用户权限聚合根
     */
    public MerchantUserPermission create() {
        this.setCreateAt(LocalDateTime.now());
        this.setStatus(Status.ENABLE);
        return this;
    }
}